package com.jhxx.controller;

import com.jhxx.entity.SysAppVersion;
import com.jhxx.service.SysAppVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Author kkk
 * Date  2020-04-10
 */
@RestController
@RequestMapping(value = "/sysAppVersion")
public class SysAppVersionController {
    @Autowired
    private SysAppVersionService sysAppVersionService;

    @RequestMapping(value = {"/list", ""}, method = RequestMethod.GET)
    public Object list() {
        List<SysAppVersion> sysAppVersions = sysAppVersionService.findAllList();
        return sysAppVersions;
    }

    @RequestMapping(value = {"/get"}, method = RequestMethod.GET)
    public Object get(@RequestParam String id) {
        SysAppVersion sysAppVersion = sysAppVersionService.get(id);
        return sysAppVersion;
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public String insert(@RequestBody SysAppVersion sysAppVersion) {
        if (sysAppVersionService.insert(sysAppVersion) > 0) {
            return "success";
        } else {
            return "failed";
        }
    }

    @RequestMapping(value = "/insertBatch", method = RequestMethod.POST)
    public String insertBatch(@RequestBody List<SysAppVersion> sysAppVersions) {
        if (sysAppVersionService.insertBatch(sysAppVersions) > 0) {
            return "success";
        } else {
            return "failed";
        }
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String update(@RequestBody SysAppVersion sysAppVersion) {
        if (sysAppVersionService.update(sysAppVersion) > 0) {
            return "success";
        } else {
            return "failed";
        }
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public String delete(@RequestBody SysAppVersion sysAppVersion) {
        if (sysAppVersionService.delete(sysAppVersion) > 0) {
            return "success";
        } else {
            return "failed";
        }
    }

}
